import { S } from '../../s';
import { IPSControl } from '../ipscontrol';
import { IPSRawItemBase } from '../ipsraw-item-base';
import { IPSRawItemContainer } from '../ipsraw-item-container';
import { IPSDBRawItemPortletPart } from './ipsdbraw-item-portlet-part';
import { PSDBPortletPartImpl } from './psdbportlet-part-impl';
import { IPSSysImage } from '../../res/ipssys-image';

export class PSDBRawItemPortletPartImpl
  extends PSDBPortletPartImpl
  implements IPSDBRawItemPortletPart, IPSRawItemContainer
{
  protected contentpscontrol: IPSControl;
  getContentPSControl(): IPSControl | null {
    if (this.contentpscontrol != null) return this.contentpscontrol;
    const value = this.M.getContentPSControl;
    if (value == null) {
      return;
    }
    this.contentpscontrol = this.findPSControl(value);
    return this.contentpscontrol;
  }

  get contentType():
    | 'RAW'
    | 'HTML'
    | 'IMAGE'
    | 'MARKDOWN'
    | 'VIDEO'
    | 'PLACEHOLDER'
    | 'DIVIDER'
    | 'INFO'
    | 'WARNING'
    | 'ERROR'
    | 'USER'
    | 'USER2' {
    return this.M.contentType;
  }

  get htmlContent(): string {
    return this.M.htmlContent;
  }

  protected psrawitem: IPSRawItemBase;
  getPSRawItem(): IPSRawItemBase | null {
    return (
      this.psrawitem ||
      (this.psrawitem = this.fillObjectModel(
        S._3ae,
        this.M.getPSRawItem,
        S._3bc,
      ) as IPSRawItemBase)
    );
  }

  protected pssysimage: IPSSysImage;
  getPSSysImage(): IPSSysImage | null {
    return (
      this.pssysimage ||
      (this.pssysimage = this.fillObjectModel(
        S._27b,
        this.M.getPSSysImage,
        S._2ad,
      ) as IPSSysImage)
    );
  }

  get portletType():
    | 'LIST'
    | 'CHART'
    | 'VIEW'
    | 'HTML'
    | 'TOOLBAR'
    | 'ACTIONBAR'
    | 'CUSTOM'
    | 'APPMENU'
    | 'CONTAINER'
    | 'RAWITEM' {
    return this.M.portletType;
  }

  get rawContent(): string {
    return this.M.rawContent;
  }

  get rawItemHeight(): number {
    return this.M.rawItemHeight != null ? this.M.rawItemHeight : 0.0;
  }

  get rawItemWidth(): number {
    return this.M.rawItemWidth != null ? this.M.rawItemWidth : 0.0;
  }
  get cls(): string {
    return 'PSDBRawItemPortletPartImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._bd || cls == S._3ba || cls == S._228) return true;
    return super.instanceof(cls);
  }
}
